package com.entmanage.base.hrm.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.entmanage.common.annotation.Log;
import com.entmanage.common.core.controller.BaseController;
import com.entmanage.common.core.domain.AjaxResult;
import com.entmanage.common.enums.BusinessType;
import com.entmanage.base.hrm.domain.HrmEmployeeEducation;
import com.entmanage.base.hrm.service.IHrmEmployeeEducationService;
import com.entmanage.common.utils.poi.ExcelUtil;
import com.entmanage.common.core.page.TableDataInfo;

/**
 * 员工教育背景子Controller
 *
 * @author lsq
 * @date 2025-09-02
 */
@Api(tags = {"hrm-HrmEmployeeEducation模块"}, description = "员工教育背景子")
@RestController
@RequestMapping("/hrm/education")
public class HrmEmployeeEducationController extends BaseController
{
    @Autowired
    private IHrmEmployeeEducationService hrmEmployeeEducationService;

    /**
     * 查询员工教育背景子列表
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrmEmployeeEducation hrmEmployeeEducation)
    {
        startPage();
        List<HrmEmployeeEducation> list = hrmEmployeeEducationService.selectHrmEmployeeEducationList(hrmEmployeeEducation);
        return getDataTable(list);
    }

    /**
     * 导出员工教育背景子列表
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:export')")
    @Log(title = "员工教育背景子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrmEmployeeEducation hrmEmployeeEducation)
    {
        List<HrmEmployeeEducation> list = hrmEmployeeEducationService.selectHrmEmployeeEducationList(hrmEmployeeEducation);
        ExcelUtil<HrmEmployeeEducation> util = new ExcelUtil<HrmEmployeeEducation>(HrmEmployeeEducation.class);
        util.exportExcel(response, list, "员工教育背景子数据");
    }

    /**
     * 获取员工教育背景子详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:query')")
    @GetMapping(value = "/{eduId}")
    public AjaxResult getInfo(@PathVariable("eduId") Long eduId)
    {
        return success(hrmEmployeeEducationService.selectHrmEmployeeEducationByEduId(eduId));
    }

    /**
     * 新增员工教育背景子
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:add')")
    @Log(title = "员工教育背景子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrmEmployeeEducation hrmEmployeeEducation)
    {
        return toAjax(hrmEmployeeEducationService.insertHrmEmployeeEducation(hrmEmployeeEducation));
    }

    /**
     * 修改员工教育背景子
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:edit')")
    @Log(title = "员工教育背景子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrmEmployeeEducation hrmEmployeeEducation)
    {
        return toAjax(hrmEmployeeEducationService.updateHrmEmployeeEducation(hrmEmployeeEducation));
    }

    /**
     * 删除员工教育背景子
     */
    @PreAuthorize("@ss.hasPermi('hrm:education:remove')")
    @Log(title = "员工教育背景子", businessType = BusinessType.DELETE)
    @DeleteMapping("/{eduIds}")
    public AjaxResult remove(@PathVariable Long[] eduIds)
    {
        return toAjax(hrmEmployeeEducationService.deleteHrmEmployeeEducationByEduIds(eduIds));
    }

    /**
     * 根据员工ID查询教育经历列表
     */
    @GetMapping("/listByEmpId/{empId}")
    public AjaxResult listByEmpId(@PathVariable Long empId) {
        List<HrmEmployeeEducation> list = hrmEmployeeEducationService.selectEducationByEmpId(empId);
        return AjaxResult.success(list);
    }
}
